package yuhao.jdbc;

import yuhao.pojo.Acount;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

public class Jdbc3 {
    public static void main(String[] args) throws Exception {

        // 1.注册驱动
        //Class.forName("com.mysql.jdbc.Driver");


        // 2.获取数据库连接
        String url = "jdbc:mysql://127.0.0.1/db6?useSSL=false";
        String username = "root";
        String password = "1234";
        Connection conn = DriverManager.getConnection(url, username, password);


        String sql = "select * from account";
        Statement sta = conn.createStatement();
        ResultSet set = sta.executeQuery(sql);
        ArrayList<Acount> list = new ArrayList<>();
        while (set.next()) {
            Integer id = set.getInt("id");
            String name = set.getString("name");
            Integer money = set.getInt("money");

            Acount acount = new Acount(id, name, money);

            }



        set.close();
        sta.close();
        conn.close();
        }



    }

